Python:lexical analyzer